/*
 * File Name:               XJsonNoPropertyResolver.cs
 * 
 * Description:             普通类
 * Author:                  lisiyu <576603306@qq.com>

 * Create Date:             2017/06/13
 */

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Reflection;

public class XJsonNoPropertyResolver : DefaultContractResolver
{
    protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
    {
        var property = base.CreateProperty(member, memberSerialization);
        property.ShouldSerialize = _ => ShouldSerialize(member);
        return property;
    }

    internal static bool ShouldSerialize(MemberInfo memberInfo)
    {
        if (memberInfo is PropertyInfo)
            return false;

        return true;
    }
}
